package com.jingtai.platform.util;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.jingtai.common.enums.DeleteFlagEnum;
import com.jingtai.common.enums.EnableStatusEnum;
import com.jingtai.common.enums.LevelEnum;
import com.jingtai.core.entity.shop.GoodsSpecificationsCustom;
import com.jingtai.platform.service.shop.GoodsSpecificationsCustomService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class SkuArrAy {

    public static String[] conversion(List<List<String>> list){
        Object sku [] = new Object[list.size()];
        for (int i = 0; i < list.size() ;i++){
            sku[i] = list.get(i).toArray(new String[list.get(i).size()]);
        }
        return process(sku);
    }

    public static String[] process(Object sku[]){
        //查询所有自定义规格
        int len = sku.length;
        if(len>=2){
            String  s1[]= (String[]) sku[0];
            int len1=s1.length;
            String  s2[]= (String[]) sku[1];
            int len2=s2.length;

            int len3=len1*len2;
            int index=0;
            String items[]=new String[len3];
            for(int i = 0; i < len1; i++) {
                for(int j = 0; j < len2; j++) {
                    items[index] = ((String[]) sku[0])[i] + "-" + ((String[]) sku[1])[j];
                    index++;
                }
            }
            // 将新组合的数组并到原数组中
            Object newArr[]=new Object[len-1];
            for(int i = 2; i < sku.length; i++) {
                newArr[i - 1] = sku[i];
            }
            newArr[0] = items;
            return process(newArr);

        }else {
            return (String[]) sku[0];
        }
    }

}
